package net.yla.smartbus.module.controller.web.ba.enums;

import net.yla.smartbus.core.api.ApiResult;
import net.yla.smartbus.core.base.BaseController;
import net.yla.smartbus.core.enums.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 默苍离
 * @date 2021/6/28 15:41
 * <p>
 * ******************************************
 * @annotation: 枚举类型 转 集合 控制器
 */
@RestController
@RequestMapping("/api/web/taxi/ba")
public class MyEnumController extends BaseController {

    /**
     * 能源类型 枚举
     *
     * @return
     */
    @PostMapping("/enums/FuelTypeEnum")
    public ApiResult getFuelTypeEnum() {
        List<KY> list = new ArrayList<>();
        FuelTypeEnum[] values = FuelTypeEnum.values();
        for (FuelTypeEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


    /**
     * 车型级别 枚举
     *
     * @return
     */
    @PostMapping("/enums/Rank")
    public ApiResult getRank() {
        List<KY> list = new ArrayList<>();
        RankEnum[] values = RankEnum.values();
        for (RankEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


    /**
     * 设备类型 枚举
     *
     * @return
     */
    @PostMapping("/enums/getDeviceTypeEnum")
    public ApiResult getDeviceTypeEnum() {
        List<KY> list = new ArrayList<>();
        DeviceTypeEnum[] values = DeviceTypeEnum.values();
        for (DeviceTypeEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


    /**
     * 运营类型 枚举
     *
     * @return
     */
    @PostMapping("/enums/OperationTypeEnum")
    public ApiResult getOperationTypeEnum() {
        List<KY> list = new ArrayList<>();
        OperationTypeEnum[] values = OperationTypeEnum.values();
        for (OperationTypeEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


    /**
     * 驾驶此车辆所需最低等级的驾照 枚举
     *
     * @return
     */
    @PostMapping("/enums/DrivingLicenseEnum")
    public ApiResult getDrivingLicenseEnum() {
        List<KY> list = new ArrayList<>();
        DrivingLicenseEnum[] values = DrivingLicenseEnum.values();
        for (DrivingLicenseEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


    /**
     * 排放标准 枚举
     *
     * @return
     */
    @PostMapping("/enums/DischargeEnum")
    public ApiResult getDischargeEnum() {
        List<KY> list = new ArrayList<>();
        DischargeEnum[] values = DischargeEnum.values();
        for (DischargeEnum value : values) {
            KY ky = new KY();
            ky.setName(value.name());
            ky.setValue(value.getValue());
            list.add(ky);
        }
        return success(list);
    }


}